﻿using System.Collections.Generic;
using System;
using System.Reflection;
using System.Runtime.Serialization;
using GraphMLComplexType;
using System.ComponentModel.DataAnnotations;
using System.Web.DomainServices;

namespace GraphInformation
{
    [DataContract]
    public class PairKeyValue
    {
        public PairKeyValue()
        {
        }

        public PairKeyValue(string key, string value)
        {
            Key = key;
            Value = value;
        }

        [DataMember]
        public Guid ID { get; set; }

        [DataMember]
        public Guid ElementID { get; set; }
 
        [DataMember]
        public String Key { get; set; }

        [DataMember]
        public String Value { get; set; }
    }

    [DataContract]
    public sealed class GraphElement
    {
        private List<PairKeyValue> m_keys;

        [DataMember]
        public Guid ID { get; set; }

        [DataMember]
        public Guid GraphID { get; set; }

        [DataMember]
        public List<PairKeyValue> Keys
        {
            get { return m_keys; }
            set { m_keys = value; }
        }


        public GraphElement()
        {
            m_keys = new List<PairKeyValue>();
        }


        [DataMember]
        public double x;

        [DataMember]
        public double y;

        [DataMember]
        public double Width;

        [DataMember]
        public double Height;

        public override string ToString()
        {
            return ID.ToString();
        }
    }

    [DataContract]
    public class GraphEdge
    {
        public GraphEdge()
        {

        }

        [DataMember]
        public Guid ID { get; set; }

        public GraphEdge(GraphElement source, GraphElement target)
        {
            Source = source.ID;
            Target = target.ID;
        }

        [DataMember]
        public Guid GraphID { get; set; }

        [DataMember]
        public Guid Source { get; set; }

        [DataMember]
        public Guid Target { get; set; }

        [DataMember]
        public Int32 Condition { get; set; }
    }

    [DataContract]
    public class Graph
    {
        [DataMember]
        public Guid ID { get; set; }

        [DataMember]
        public List<GraphEdge> Edges
        {
            get;
            set;
        }

        [DataMember]
        public List<GraphElement> Vertices
        {
            get;
            set;
        }

        [DataMember]
        public double Width;

        [DataMember]
        public double Height;
    }
}